package com.gitee.wsl.time.chinese

import kotlin.test.DefaultAsserter.assertEquals
import kotlin.test.Test


/**
 * 起运测试
 */
class YunTest {
    @Test
    fun test1() {
        val solar = Solar(1981, 1, 29, 23, 37, 0)
        val lunar = solar.lunar
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(0)
        assertEquals("起运年数", 8, yun.startYear)
        assertEquals("起运月数", 0, yun.startMonth)
        assertEquals("起运天数", 20, yun.startDay)
        assertEquals("起运阳历", "1989-02-18", yun.startSolar.toYmd())
    }

    @Test
    fun test2() {
        val lunar = Lunar(2019, 12, 12, 11, 22, 0)
        println(lunar.month)
        println(lunar.toFullString())
        println(lunar.solar.toFullString())
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(1)
        assertEquals("起运年数", 0, yun.startYear)
        assertEquals("起运月数", 1, yun.startMonth)
        assertEquals("起运天数", 0, yun.startDay)
        assertEquals("起运阳历", "2020-02-06", yun.startSolar.toYmd())
    }

    @Test
    fun test3() {
        val solar = Solar(2020, 1, 6, 11, 22, 0)
        val lunar = solar.lunar
        println(lunar.month)
        println(lunar.toFullString())
        println(lunar.solar.toFullString())
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(1)
        assertEquals("起运年数", 0, yun.startYear)
        assertEquals("起运月数", 1, yun.startMonth)
        assertEquals("起运天数", 0, yun.startDay)
        assertEquals("起运阳历", "2020-02-06", yun.startSolar.toYmd())
    }

    @Test
    fun test4() {
        val solar = Solar(2022, 3, 9, 20, 51, 0)
        val lunar = solar.lunar
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(1)
        assertEquals("起运阳历", "2030-12-19", yun.startSolar.toYmd())
    }

    @Test
    fun test5() {
        val solar = Solar(2022, 3, 9, 20, 51, 0)
        val lunar = solar.lunar
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(1, 2)
        assertEquals("起运年数", 8, yun.startYear)
        assertEquals("起运月数", 9, yun.startMonth)
        assertEquals("起运天数", 2, yun.startDay)
        assertEquals("起运阳历", "2030-12-12", yun.startSolar.toYmd())
    }

    @Test
    fun test6() {
        val solar = Solar(2018, 6, 11, 9, 30, 0)
        val lunar = solar.lunar
        val eightChar = lunar.eightChar
        val yun = eightChar!!.getYun(0, 2)
        assertEquals("起运阳历", "2020-03-21", yun.startSolar.toYmd())
    }
}
